#ifndef _XP_LNX_IPVS_H_
#define _XP_LNX_IPVS_H_

#include <xp/types.h>
#include <xp/macros.h>

typedef struct xp_ipvs_timeout_t xp_ipvs_timeout_t;

struct xp_ipvs_timeout_t
{
	int tcp;
	int tcp_fin;
	int udp;
};

typedef struct xp_ipvs_t xp_ipvs_t;

struct xp_ipvs_t
{
	int sockfd;
	xp_ipvs_timeout_t timeout;
};

#ifdef __cplusplus
extern "C" {
#endif

xp_ipvs_t* xp_ipvs_open (
	void
);

void xp_ipvs_close (
	xp_ipvs_t* ipvs
);

int xp_ipvs_flush (
	xp_ipvs_t* ipvs
);

int xp_ipvs_insertnroutewithfwmark (
	xp_ipvs_t*  ipvs, 
	xp_uint32_t addr,
	int         weight,
	xp_uint32_t fwmark
);

int xp_ipvs_deletenroutewithfwmark (
	xp_ipvs_t*  ipvs, 
	xp_uint32_t addr,
	int         weight,
	xp_uint32_t fwmark 
);

int xp_ipvs_settimeout (
	xp_ipvs_t* ipvs, 
	const xp_ipvs_timeout_t* timeout
);

int xp_ipvs_unsettimeout (
	xp_ipvs_t* ipvs
);

int xp_ipvs_insertpersistentservicewithfwmark (
	xp_ipvs_t*       ipvs,
	const xp_char_t* sched,
	int              ptimeout,
	xp_uint32_t      fwmark
);

int xp_ipvs_deletepersistentservicewithfwmark (
	xp_ipvs_t*       ipvs,
	const xp_char_t* sched,
	int              ptimeout,
	xp_uint32_t      fwmark
);

#ifdef __cplusplus
}
#endif

#endif
